package com.example.ch6;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class DealWithLogin
 */
public class DealWithLogin extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Cookie cookie = new Cookie("Name", request.getParameter("username"));
		cookie.setMaxAge(20 * 60);
		response.addCookie(cookie);
		response.sendRedirect("session02.do");
		/*RequestDispatcher dispatcher = request.getRequestDispatcher("session02.do");
		dispatcher.forward(request, response);*/
	}

}
